/*
 * Funambol is a mobile platform developed by Funambol, Inc. 
 * Copyright (C) 2008 Funambol, Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by
 * the Free Software Foundation with the addition of the following permission 
 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
 * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License 
 * along with this program; if not, see http://www.gnu.org/licenses or write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA.
 * 
 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by Funambol" logo. If the display of the logo is not reasonably 
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by Funambol".
 */

#ifndef INCL_FUN_EVENT
#define INCL_FUN_EVENT
    
#include <sqlite3.h>
#include "base/util/StringBuffer.h"
#include "PIMItem.h"
#include "Date.h"
#include "Recurrence.h"
#include "Timezone.h"
#include "Alarm.h"


typedef enum {
    NormalEvt,
    PersonalEvt,
    PrivateEvt,
    ConfidentialEvt    
} Sensitivity;

typedef enum {
    ImportanceLow,
    ImportanceNormal,
    ImportanceHigh
} Importance;

typedef enum {
    Free,
    Tentative,
    Busy,
    OutOfOffice
} BusyStatus;


using namespace Funambol;


class Event : public PIMItem {
    
private:
    
    /**
    * The event is all day (true) or not (false);
    */
    bool allDayEvent;
    
    /**
    * The start date of the event. Only date year, month, day are used for an all day event
    */
    Date start;
    
    /**
    * The end date of the event. Only date year, month, day are used for an all day event
    */
    Date end;
    
    /**
    * The event is recurring (true) or not (false);
    */    
    bool isRecurring;
    
    /**
    * The reminder is set(true) or not (false);
    */    
    bool reminderSet;
     
    /**
    * The categories of the event. More categories are separated with ,
    */   
    StringBuffer categories;
    
    /**
    * The subject of the event
    */   
    StringBuffer subject;

    /**
    * The body of the event
    */   
    StringBuffer body;
    
    /**
    * The location of the event
    */   
    StringBuffer location;
    
    /**
    * The status of the event
    */           
    BusyStatus busyStatus; 
    
    /**
    * The importance of the event
    */   
    Importance importance; 

    /**
    * The sensitivity of the event
    */       
    Sensitivity sensitivity; 

    /**
    * The Timezone of the event 
    */       
    Timezone timezone;
    
    /**
    * The calendar the event belongs. It could be of different type 
    * depending on the 
    */
    StringBuffer calendar;
    
    /**** specific for platform iphone ****/
    /**
    * Represents the event id that the main event is related.
    * This is used when there is a Recurring event and an occurrence is
    * modified. So the OS keep trace of the original one setting in this field the 
    * original id this event comes from
    */
    StringBuffer orig_event_id;
    
    /**
    * Represent the original start date the event should start.
    */
    StringBuffer orig_start_date;
    
    /**
     * It represents the alarm of the event. 
     */
    Alarm* alarm;
    
    /**
     * The Recurrence parameters of the event. It is null if the recurrence doesn't exist. Populated othewise.
     */       
    Recurrence* recurrence;
    
    
public:
    
    Event() : PIMItem(EventType) {
        allDayEvent = false;        
        isRecurring = false;
        reminderSet = false;
        calendar = "2";
        busyStatus = Free;
        importance = ImportanceNormal;
        sensitivity = NormalEvt;
        orig_event_id = "0";
        orig_start_date = "0";   
        alarm = NULL;
        recurrence = NULL;
    }
    
    ~Event() {
        if (alarm) { delete alarm; }
        if (recurrence) { delete recurrence; }
    
    }
    
    void setAllDayEvent(bool v) { allDayEvent = v; }
    bool getAllDayEvent() { return allDayEvent; }
    
    void setStart(Date& d) { start = d; }
    Date& getStart() { return start; }
    
    void setEnd(Date& d) { end = d; }
    Date& getEnd() { return end; }    
    
    void setIsRecurring(bool v) { isRecurring = v; }
    bool getIsRecurring() { return isRecurring; }
    
    void setReminderSet(bool v) { reminderSet = v; }
    bool getReminderSet() { return reminderSet; }    

    void setCategories(const char* v) { categories = v; }
    const char* getCategories() { return categories; }    
    
    void setSubject(const char* v) { subject = v; }
    const char* getSubject() { return subject; }        

    void setBody(const char* v) { body = v; }
    const char* getBody() { return body; }            
    
    void setLocation(const char* v) { location = v; }
    const char* getLocation() { return location; }            
        
    void setBusyStatus(BusyStatus v) { busyStatus = v; }
    BusyStatus getBusyStatus() { return busyStatus; }
    
    void setImportance(Importance v) { importance = v; }
    Importance getImportance() { return importance; }    

    void setSensitivity(Sensitivity v) { sensitivity = v; }
    Sensitivity getSensitivity() { return sensitivity; }    
    
    void setEventTimezone(Timezone& t) { timezone = t; }
    Timezone& getEventTimezone() { return timezone; }
        
    void setCalendar(const char* v) { calendar = v; }
    const char* getCalendar() { return calendar; }  
       
    void setorig_event_id(const char* v) { orig_event_id = v; }
    const char* getorig_event_id() { return orig_event_id; }  
        
    void setorig_start_date(const char* v) { orig_start_date = v; }
    const char* getorig_start_date() { return orig_start_date; }  
    
    void setRecurrence(Recurrence* r) { recurrence = r; }
    Recurrence* getRecurrence() { return recurrence; }      
    
    void setAlarm(Alarm* a) { alarm = a; }
    Alarm* getAlarm() { return alarm; }      


};

#endif

